home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / Mic-1 v1.0 / Project and Source / Source / mic_global_functions.cpp < prev    next >
Text File  |  1996-04-09  |  1KB  |  88 lines

  1. /*
  2.     "global_functions.cpp"
  3.     
  4.     This is just a real simple file containing a Death proc.
  5. */
  6.  
  7. #include "mic_global_functions.h"
  8. #include "keymap.h"
  9.  
  10. void Death (short resCode)
  11. {
  12.     StopAlert(resCode, nil);
  13.     ExitToShell();
  14. }
  15.  
  16. void Pause (void)
  17. {
  18.     while (!Button());
  19.     while (Button());
  20. }
  21.  
  22. void Beep (void)
  23. {
  24.     SysBeep(5);
  25. }
  26.  
  27. short Min (short x, short y)
  28. {
  29.     return (x < y) ? x : y;
  30. }
  31.  
  32. short Max (short x, short y)
  33. {
  34.     return (x > y) ? x : y;
  35. }
  36.  
  37. void Catenate (Str255 Str1, Str255 Str2)
  38. {
  39.     short Length;
  40.     
  41.     Length = Min(Str2[0], 255 - Str1[0]);
  42.     if (Length > 0)
  43.     {
  44.         BlockMove(Str2 + 1, Str1 + Str1[0] + 1, (long)Length);
  45.         Str1[0] += Length;
  46.     }
  47. }
  48.  
  49. void CopyString (StringPtr sourceStr, StringPtr destStr)
  50. {
  51.     short copyLen;
  52.     
  53.     copyLen = sourceStr[0];
  54.     if (copyLen > 0)
  55.     {
  56.         BlockMove(sourceStr, destStr, (long) copyLen + 1L);
  57.     }
  58. }
  59.  
  60. Boolean EqualStrings (Str255 Str1, Str255 Str2)
  61. {
  62.     short i = 0;
  63.     Boolean equal = true;
  64.     
  65.     if (Str1[0] != Str2[0])
  66.         return false;
  67.     else
  68.     {
  69.         while (equal)
  70.         {
  71.             if (Str1[i] != Str2[i])
  72.                 equal = false;
  73.             else i++;
  74.         }
  75.         return true;
  76.     }
  77.     return equal;
  78. }
  79.  
  80. Boolean CheckForEscapeKey (void)
  81. {
  82.     KeyMap Keys;
  83.     GetKeys(Keys);
  84.     
  85.     if (Keys[ESC_POS] & ESC_KEY)
  86.         return true;
  87.     else return false;
  88. }